Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the TLS security level early and on context #685

Conversation

DimitriPapadopoulos
Copy link
Collaborator

@DimitriPapadopoulos DimitriPapadopoulos commented May 3, 2020

The existing code does work for cipher negotiation with old (FortiOS 4?) FortiGate appliances, but not for personal certificates (SHA-1 certificates).

Two reasons I can see:

  • SSL_set_cipher_list() was called after messing with certificates.
  • SSL_set_cipher_list() applies only to the SSL connection, not to certificates, call SSL_CTX_set_cipher_list() on context instead.

This change addresses both of the above issues.

See SSL(7) man page:

SSL_CTX (SSL Context)
This is the global context structure which is created by a server or client once per program life-time and which holds mainly default values for the SSL structures which are later created for the connections.

SSL (SSL Connection)
This is the main SSL/TLS structure which is created by a server or client per established connection. This actually is the core structure in the SSL API. At run-time the application usually deals with this structure which has links to mostly all other structures.

@DimitriPapadopoulos DimitriPapadopoulos changed the title Properly set the TLS security level Set the TLS security level early enough May 3, 2020
@DimitriPapadopoulos DimitriPapadopoulos removed the request for review from mrbaseman May 4, 2020 08:33
@DimitriPapadopoulos DimitriPapadopoulos linked an issue May 4, 2020 that may be closed by this pull request
@DimitriPapadopoulos
Copy link
Collaborator Author

Unfortunately this does not help with #682. Will need to generate an SHA-1 certificate to investigate.

@DimitriPapadopoulos DimitriPapadopoulos marked this pull request as draft May 4, 2020 08:35
@DimitriPapadopoulos DimitriPapadopoulos force-pushed the seclevel1_sha1_certificate branch 2 times, most recently from dd04c5d to 8214bcb Compare May 4, 2020 10:24
@DimitriPapadopoulos DimitriPapadopoulos changed the title Set the TLS security level early enough Set the TLS security level early and on context May 4, 2020
@DimitriPapadopoulos
Copy link
Collaborator Author

@martinetd In order to support SHA-1 personal certificates (see #682), I have decided to call SSL_CTX_set_min_proto_version() and SSL_CTX_set_cipher_list() on the ctx context instead of calling SSL_set_min_proto_version() and SSL_set_cipher_list() on the ssl connection only. Does this sound OK to you?

@DimitriPapadopoulos DimitriPapadopoulos marked this pull request as ready for review May 4, 2020 10:33
Copy link
Contributor

@martinetd martinetd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the @ mention -- it looks safe to me, man page says "The list of ciphers is inherited by all ssl objects created from ctx." and it is create afterwards so should be ok.

(While I'm on the man page I see this doesn't affect TLSv1.3, which should use SSL_CTX_set_ciphersuites instead.. but the default value looks sensible enough so I guess we don't need to; anyway unrelated to this change)

@DimitriPapadopoulos
Copy link
Collaborator Author

Thank you for looking into this. About TLSv1.3, see #687.

The existing code does work for cipher negotiation with old
(FortiOS 4?) FortiGate appliances, but not for personal certificates
(SHA-1 certificates).

Two reasons I can see:
* SSL_set_cipher_list() was called after messing with certificates.
* SSL_set_cipher_list() applies only to the SSL connection, not to
  certificates, call SSL_CTX_set_cipher_list() on context instead.

This change addresses both of the above issues.

See SSL(7) man page:
https://www.openssl.org/docs/man1.1.1/man7/ssl.html#DATA-STRUCTURES

SSL_CTX (SSL Context)
This is the global context structure which is created by a server or client once per program life-time and which holds mainly default values for the SSL structures which are later created for the connections.

SSL (SSL Connection)
This is the main SSL/TLS structure which is created by a server or client per established connection. This actually is the core structure in the SSL API. At run-time the application usually deals with this structure which has links to mostly all other structures.
Copy link
Collaborator

@mrbaseman mrbaseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense to me (although I have to admit that am not so familiar with the internals of openssl). I have tested this with one of my vpns where I'm using a client certificate to log in. At least this is not broken. I'm not sure how I could test if this solves the problem that it aims to address, but I think in #682 this has already been confirmed.

@DimitriPapadopoulos DimitriPapadopoulos merged commit 342c8aa into adrienverge:master May 6, 2020
@DimitriPapadopoulos DimitriPapadopoulos deleted the seclevel1_sha1_certificate branch May 6, 2020 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ca md too weak
3 participants